home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Multimedia / Buzz 1.2 / BuzzME126.exe / Dev / Dsplib / resample.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-26  |  1.5 KB  |  63 lines

  1. #ifndef __BUZZ_DSPLIB_RESAMPLE_H
  2. #define __BUZZ_DSPLIB_RESAMPLE_H
  3.  
  4. typedef unsigned char byte;
  5. typedef unsigned short word;
  6. typedef unsigned long dword;
  7.  
  8. // interpolation modes
  9. #define RSI_NONE        0        // nearest sample (no interpolation) [fast, poor quality]
  10. #define RSI_LINEAR        1        // linear interpolation                 [quite fast, better quality]
  11.  
  12. // amp modes
  13. #define RSA_ONE            0        // amp = 1.0
  14. #define RSA_CONSTANT    1        // constant amp
  15. #define RSA_LINEAR_INTP    2        // linear amp interpolation
  16.  
  17. // step modes
  18. #define RSS_ONE            0        // step = 1.0
  19. #define RSS_CONSTANT    1        // constant step
  20.  
  21. // flags
  22. #define RSF_ADD            1        // add input to output instead of moving
  23. #define RSF_FLOAT        2        // input samples are 32bit floats (16bit integers by default)
  24.  
  25. #define RS_STEP_FRAC_BITS    24
  26.  
  27. class CResamplerParams
  28. {
  29. public:
  30.     void SetStep(double const s)
  31.     {
  32.         StepInt = (int)s;
  33.         StepFrac = (int)((s - StepInt) * (1 << RS_STEP_FRAC_BITS));
  34.     }
  35.  
  36. public:
  37.     void *Samples;                // ptr to first sample
  38.     int numSamples;                // number of samples (or loop)  
  39.     int LoopBegin;                // zero based index to Samples, -1 = no loop
  40.     int StepInt;
  41.     dword StepFrac;
  42.     float AmpStep;                // used if AmpMode == RSA_LINEAR_INTP
  43.  
  44.     byte Interpolation;            // one of RSI_*
  45.     byte AmpMode;                // one of RSA_*
  46.     byte StepMode;                // one of RSS_*
  47.     byte Flags;                    // any of RSF_* ORred
  48.  
  49. };
  50.  
  51. class CResamplerState
  52. {
  53. public:
  54.     int PosInt; 
  55.     dword PosFrac;
  56.     float Amp;
  57.     bool Active;                    
  58. };
  59.  
  60.  
  61.  
  62. #endif
  63.